The POP3 protocol is used by a client to access and download messages held temporarily by the mail server. POP was developed largely because SMTP lacks a method for queuing messages on the recipient's mail server. POP provides a system for queuing messages and allows the user to periodically log in to the mail server to download messages. This greatly reduces the strain of maintaining a constant and resident connection on both mail servers and user machines.
A POP session consists of the client and server exchanging commands and responses until the session is terminated. This session can be broken down into three states: authorization state, transaction state, and update state.
A POP3 session begins with the server (normally) listening for connections on port 110. The authorization state begins when a client makes a TCP connection and the server issues a greeting. The client must issue the USER command followed by its user identification. If the server responds with a positive success indicator ("+OK"), the user may issue the PASS command followed by its password. If the server again issues a positive success indicator ("+OK"), the server acquires the client's associated mail-drop, and the session moves into the transaction state. Here is an example:
Server: <wait for connection on TCP port 110> Client: <open connection> Server: +OK dewey POP3 server ready Client: USER mrose Server: +OK mrose Client: PASS secret Server: +OK mrose's maildrop has 2 messages (320 octets)
The session now enters the transaction state.
The transaction state consists of the client issuing one of several commands to which the server responds positively or negatively. These commands are used to acquire information about the mail located on the server, or to retrieve mail from the server. Commands include:
The transaction state can take many forms. The following shows a typical dialogue between client and server:
Client: STAT Server: +OK 2 320 Client: LIST Server: +OK 2 messages (320 octets) Server: 1 120 Server: 2 200 Server: . Client: RETR 1 Server: +OK 120 octets Server: < the POP3 server sends message 1 > Server: . Client: DELE 1 Server: +OK message 1 deleted Client: RETR 2 Server: +OK 200 octets Server: < the POP3 server sends message 2 > Server: . Client: DELE 2 Server: +OK message 2 deleted Client: QUIT
Once the QUIT command is issued, the transaction state is over and the session moves into the update state.
In the update state, the server deletes all messages marked for deletion, releases resources associated with the client's mail-drop, and closes the TCP connection.
For more detailed information about the POP3 protocol, refer to RFC 1939.